home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <dos.h>
- #include <direct.h>
- #include <conio.h>
-
- #include "lantasti.h"
-
- #define DOS 0x21
- #define NETBIOS 0x5C
- #define DELIM "+, "
-
- /* structure to allow easy access to both segment and offset portions of
- far pointers */
- #define LIST_SIZE 50
- #define NAME_SIZE 20
- typedef struct LIST {
- int num_servers;
- char server[LIST_SIZE][NAME_SIZE];
- } LIST;
-
- /* definitions to save typing time */
- #define C_SERVER list->server[i % list->num_servers]
-
- struct SEGOFFS {
- unsigned offs;
- unsigned seg;
- };
-
- typedef union POINTER {
- unsigned char *ptr;
- struct SEGOFFS l;
- } POINTER;
-
- /***********************************************************************
- Delete leading and trailing blanks.
- ***********************************************************************/
- void dltb(string)
- char *string;
- {
- int i;
-
- i = strspn(string, " ");
-
- if (i) strcpy(string,string + i);
-
- i = strlen(string) - 1;
- while (i && (string[i] == ' ')) {
- string[i--] = '\0';
- }
- }
-
- /* getstring ********************************************************************
- Get a string from the console -- takes a pointer to a string buffer, the
- longest permissible length and two switches. The empty switch determines
- whether or not the user is allowed to enter an empty string. If TRUE, he
- can, if FALSE, he must enter something. The shown switch determines
- whether or not input is echoed to the screen, TRUE if echoed, FALSE if
- invisible
- *****************************************************************************/
- void getstring(prompt,buffer,length,empty,shown)
- char *prompt,*buffer;
- int length,empty,shown;
- {
- fprintf(stdout,"%s",prompt);
- fgets(buffer,length,stdin);
- if (buffer[strlen(buffer) - 1] == '\n') buffer[strlen(buffer) - 1] = 0;
- while (!(strlen(buffer) || empty)) {
- fprintf(stdout,"%s",prompt);
- fgets(buffer,length,stdin);
- if (buffer[strlen(buffer) - 1] == '\n') buffer[strlen(buffer) - 1] = 0;
- }
- }
-
- /* error ********************************************************************
- Traps for system errors and prints a happy message.
- *****************************************************************************/
- void error(code,message)
- int code;
- char *message;
- {
- char *ptr;
-
- if (code) {
- ptr = get_error_text(code);
- puts(ptr);
- }
- else puts(message);
- }
-
- /* do_userlist ********************************************************************
- Breaks apart the names and checks them against the list of logged in folks.
- Prints its answer.
- *****************************************************************************/
- int net_send(dest,message,type)
- char *dest;
- char *message;
- int type;
- {
- struct msg_buffer msg;
- struct SREGS segregs;
- union REGS registers;
- union POINTER ptr;
-
- strcpy(msg.text,message);
- strcpy(msg.destination,strupr(dest));
- strcpy(msg.server,"");
- strcpy(msg.user,"");
- msg.type = type;
- ptr.ptr = (char *) &msg;
-
- segregs.ds = ptr.l.seg;
- registers.x.si = ptr.l.offs;
- registers.x.ax = 0x5f98;
-
- intdosx(®isters,®isters,&segregs);
- }
-
- /* main ********************************************************************
- *****************************************************************************/
- int main(argc,argv)
- int argc;
- char *argv[];
- {
- union REGS regs;
- int msgflag,i;
- char string[160];
-
- puts("NRUN utility for LANtastic -- Copyright 1990 by SoftMagic, Inc.");
- puts("All rights reserved.");
- puts("Thanks for trying this slightly dangerous BETA TEST VERSION!!\n");
-
- if (argc < 3) {
- puts("Usage: NRUN <machines> <command>");
- puts(" Runs the given command (any valid DOS command) on another");
- puts(" machine or group of machines on the network. Using the '*'");
- puts(" character for the machine name will run the command on ALL");
- puts(" the machines on your network.");
- puts(" Note that you must run the SoftMagic Resident Extension Module");
- puts(" (RXM.COM) on all the machines that you intend to control remotely.");
- exit(0);
- }
-
- /* get the current message state (it winds up in regs.h.dl) */
- regs.x.ax = 0x5F9A;
- intdos(®s,®s);
- msgflag = regs.h.dl;
-
- /* don't beep or pop while we're doing this */
- regs.x.ax = 0x5F9B;
- regs.h.dl = msgflag & 0x2;
- intdos(®s,®s);
-
- if (argv[1][0] == '*') argv[1][0] = 0;
-
- strcpy(string,argv[2]);
- for (i = 3; i < argc; i++) {
- strcat(string," ");
- strcat(string,argv[i]);
- }
-
- net_send(argv[1],string,0x81);
-
- /* restore message flag */
- regs.x.ax = 0x5F9B;
- regs.h.dl = msgflag;
- intdos(®s,®s);
- }